<?php
/**
 * @name AddressController
 * @author xuebingwang
 * @desc 收货地址控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
*/
class AddressController extends MemberController {
    
    /** 
    * 默认动作，首页
    * Yaf支持直接把Yaf\Request_Abstract::getParam()得到的同名参数作为Action的形参
    * 对于如下的例子, 当访问http://yourhost/y/index/index/index/name/yantze 的时候, 你就会发现不同
    */
    public function indexAction(){

        //var_dump($this->user);
        $add_list = array();
        $address = array(
                    'id'=>50,
                    'title'=>'',
                    'uid'=>77,
                    'consignee'=>'王xx',
                    'district'=>0,
                    'address'=>'',
                    'zipcode'=>'',
                    'telphone'=>'',
                    'mobile'=>'18620300000',
                    'status'=>1,
                );
        $add_list[] = $address;
        $address = array(
                    'id'=>51,
                    'title'=>'',
                    'uid'=>77,
                    'consignee'=>'王xx1',
                    'district'=>0,
                    'address'=>'',
                    'zipcode'=>'',
                    'telphone'=>'',
                    'mobile'=>'18620300001',
                    'status'=>1,
                );
        $add_list[] = $address;
        
        $this->getView()->assign('add_list',$add_list);
        
        $type = intval($this->getRequest()->getQuery('type'));
        $urls = array('/cart/settle','');

        $this->getView()->assign('type',$type);
        $this->getView()->assign('back_url',$urls[$type]);
    }
    
    public function addAction(){
        
        $type = intval($this->getRequest()->getQuery('type'));
        $urls = array('/cart/settle','');
        
        $this->getView()->assign('back_url',$urls[$type]);
        $this->getView()->assign('type',$type);
    }
    
    public function editAction($address_id=0){
        
    }
    
    public function saveAction(){
    	
        $this->check_params();
        
        $data = [
                'consignee'=>$this->getRequest()->getPost('consignee'),
                'mobile'=>$this->getRequest()->getPost('mobile'),
                'district'=>$this->getRequest()->getPost('district'),
                'address'=>$this->getRequest()->getPost('address'),
                'zipcode'=>$this->getRequest()->getPost('zipcode'),
        ];
        
        $this->success('保存成功！');
    }
}
